package yanyan.com.tochar;

import android.util.Base64;

import com.alibaba.fastjson.JSON;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import yanyan.com.tochar.beans.AllInfo;


public class Test {
    public static void main(String arg[]){
        String ss="http://39.106.162.25:8082/appInfo/getAll";
        String s = Base64.encodeToString(ss.getBytes(), Base64.DEFAULT);
        System.out.println(s);

    }

    /**
     * 获取网页源码
     * @param url
     * @return
     */
    public static String getHtml(String url){
        BufferedReader bf=null;
        String res="";
        try {
            URL u=new URL(url);
            HttpURLConnection urlConnection = (HttpURLConnection) u
                    .openConnection();// 打开URL
            bf=new BufferedReader(new InputStreamReader(urlConnection.getInputStream(),"gb2312"));
            StringBuffer sb=new StringBuffer();
            String line;
            while ((line=bf.readLine())!=null){
                sb.append(line+"\n");
            }
            res=sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                bf.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return res;
    }
}
